package net.qhzw.vip.qiyu.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import net.qhzw.vip.qiyu.entity.Logistics;
import net.qhzw.vip.qiyu.result.JsonResult;
import net.qhzw.vip.qiyu.service.LogisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/logistics")
@RestController
@Api(tags = "物流接口")
public class LogisticsController {


    @Autowired
    private LogisticsService logisticsService;


    @GetMapping("/{orderNumber}")
    public JsonResult<List<Logistics>> findList(@PathVariable String orderNumber) {
        List<Logistics> list = logisticsService.list(new LambdaQueryWrapper<Logistics>()
                .eq(Logistics::getOrderNumber, orderNumber).orderByDesc(Logistics::getCreated));
        return JsonResult.ok(list);
    }


    @PostMapping
    public JsonResult update(@RequestBody Logistics logistics) {
        logisticsService.save(logistics);
        return JsonResult.ok();
    }


}
